package UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPReceiver {
    public static void main(String[] args) {
        try {
            //创建socket
            DatagramSocket socket = new DatagramSocket(6666);

            //创建packet
            byte[] data = new byte[100];
            DatagramPacket packet = new DatagramPacket(data, 100);
            System.out.println("waiting");
            //接收数据
            socket.receive(packet);
            System.out.println(new String(data).trim());
            socket.close();
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
